package net.uman.framework.modules.search;

import java.text.SimpleDateFormat;
import java.util.Date;

public class FieldDesc {
	String name;
	String value;
	boolean searchable;
	
	public FieldDesc() {		
	}
	
	public FieldDesc(String name, String value) {
		this(name, value, true);
	}
	
	public FieldDesc(String name, Date date) {
		this(name, getValue(date), true);
	}

	public FieldDesc(String name, String value, boolean searchable) {
		this.name = name;
		this.value = value;
		this.searchable = searchable;
	}
	
	public FieldDesc(String name, Date date, boolean searchable) {
		this(name, getValue(date), searchable);
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getValue() {
		return value;
	}
	public void setValue(String value) {
		this.value = value;
	}
	public boolean isSearchable() {
		return searchable;
	}
	public void setSearchable(boolean searchable) {
		this.searchable = searchable;
	}
	
	private static String getValue(Date date) {
		if (date == null) {
			return "";
		}
		return new SimpleDateFormat("yyyy-MM-dd").format(date);
	}
}
